﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BLL;
using WeChat.Common;

namespace WeChat.Manager
{
    public partial class MediaManager : System.Web.UI.Page
    {
        MediaBLL md = new MediaBLL();
        GetMedia dm = new GetMedia();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                selectedIndexChanged(sender,e);
            }
        }

        //绑定并显示素材
        protected void selectedIndexChanged(object sender, EventArgs e)
        {
            string type = DropDownList1.Text;
            DataSet ds = md.getMedias(type);
            DataTable dt = ds.Tables[0];
            mediaShow.DataSource = dt;
            mediaShow.DataBind();
        }

        //删除素材
        protected void mediaShow_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "delete")
            {
                string mediaID = e.CommandArgument.ToString();
                string res = dm.delMedia(mediaID);
                selectedIndexChanged(source,e);
                Label1.Text = res;
                this.Page.ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>tips();</script>");
            }
        }
     
    }
}
